package com.sx.pipeline.repos.http.service

import com.sx.pipeline.app.config.BaseEntity
import com.sx.pipeline.repos.http.req.JoinBusinessDTO
import com.sx.pipeline.repos.http.res.IdentityVO
import com.sx.pipeline.repos.http.res.MyUnitListVO
import io.reactivex.rxjava3.core.Observable
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

/**
 * @Author: YY
 * @Date: 2022/6/25
 * @Desc: 切换企业/身份
 */
interface IBusinessService {

    /**
     * 查询用户可申请的身份列表
     */
    @GET("/api/system/unit/getUnitIdentity")
    fun getUnitIdentity(): Observable<BaseEntity<List<IdentityVO>>>

    /**
     * 申请单位创建身份
     */
    @POST("/api/system/unit/applyIdentity")
    fun applyIdentity(@Query("identity") identity: String): Observable<BaseEntity<Any>>

    /**
     * 获取可切换的单位列表
     */
    @GET("/myUnit")
    fun getSwitchUnitList(): Observable<BaseEntity<List<MyUnitListVO>>>

    /**
     * 切换单位和身份
     */
    @POST("/toggleLogin")
    fun switchUnitIdentity(
        @Query("identity") identity: String,
        @Query("unitId") unitId: Int
    ): Observable<BaseEntity<IdentityVO>>

    /**
     * 加入企业
     */
    @POST("/api/system/unit/addUnit")
    fun joinBusiness(@Body dto: JoinBusinessDTO): Observable<BaseEntity<Any>>
}